package com.hig.ledger.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hig.ledger.mapper.LedgerSpecialVehiclesMapper;
import com.hig.ledger.domain.LedgerSpecialVehicles;
import com.hig.ledger.service.ILedgerSpecialVehiclesService;

/**
 * 特种车辆清单Service业务层处理
 *
 * @author scp
 * @date 2024-09-22
 */
@Service
public class LedgerSpecialVehiclesServiceImpl implements ILedgerSpecialVehiclesService
{
    @Autowired
    private LedgerSpecialVehiclesMapper ledgerSpecialVehiclesMapper;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询特种车辆清单
     *
     * @param id 特种车辆清单ID
     * @return 特种车辆清单
     */
    @Override
    public LedgerSpecialVehicles selectLedgerSpecialVehiclesById(Long id)
    {
        return ledgerSpecialVehiclesMapper.selectLedgerSpecialVehiclesById(id);
    }

    /**
     * 查询特种车辆清单列表
     *
     * @param ledgerSpecialVehicles 特种车辆清单
     * @return 特种车辆清单
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<LedgerSpecialVehicles> selectLedgerSpecialVehiclesList(LedgerSpecialVehicles ledgerSpecialVehicles)
    {
        return ledgerSpecialVehiclesMapper.selectLedgerSpecialVehiclesList(ledgerSpecialVehicles);
    }

    /**
     * 新增特种车辆清单
     *
     * @param ledgerSpecialVehicles 特种车辆清单
     * @return 结果
     */
    @Override
    public int insertLedgerSpecialVehicles(LedgerSpecialVehicles ledgerSpecialVehicles)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        ledgerSpecialVehicles.setCreateBy(loginUser.getUser().getUserName());
        ledgerSpecialVehicles.setDeptId(loginUser.getUser().getDeptId());
//        long id = ledgerSpecialVehiclesMapper.getNextId();
//        ledgerSpecialVehicles.setId(id);
        ledgerSpecialVehicles.setCreateTime(DateUtils.getNowDate());
        return ledgerSpecialVehiclesMapper.insertLedgerSpecialVehicles(ledgerSpecialVehicles);
    }

    /**
     * 修改特种车辆清单
     *
     * @param ledgerSpecialVehicles 特种车辆清单
     * @return 结果
     */
    @Override
    public int updateLedgerSpecialVehicles(LedgerSpecialVehicles ledgerSpecialVehicles)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        ledgerSpecialVehicles.setUpdateBy(loginUser.getUser().getUserName());
        ledgerSpecialVehicles.setUpdateTime(DateUtils.getNowDate());
        return ledgerSpecialVehiclesMapper.updateLedgerSpecialVehicles(ledgerSpecialVehicles);
    }

    /**
     * 批量删除特种车辆清单
     *
     * @param ids 需要删除的特种车辆清单ID
     * @return 结果
     */
    @Override
    public int deleteLedgerSpecialVehiclesByIds(Long[] ids)
    {
        return ledgerSpecialVehiclesMapper.deleteLedgerSpecialVehiclesByIds(ids);
    }

    /**
     * 删除特种车辆清单信息
     *
     * @param id 特种车辆清单ID
     * @return 结果
     */
    @Override
    public int deleteLedgerSpecialVehiclesById(Long id)
    {
        return ledgerSpecialVehiclesMapper.deleteLedgerSpecialVehiclesById(id);
    }
}
